package com.iot.service;
import com.iot.mapper.TheartbeatMapper;
import com.iot.pojo.MTheartbeat;
import com.iot.util.BaseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TheartbeatServiceImpl   extends BaseServiceImpl<MTheartbeat> implements TheartbeatService {
@Autowired
private TheartbeatMapper mapper;
@Override
public BaseMapper<MTheartbeat> getMapper() {  return mapper;  }

    @Override
    public int insert(MTheartbeat mTheartbeat) throws Exception {
        int count = 0;
        count=mapper.getRecordCount("");
        if (count>0){
            throw new Exception("该信息只能设置一条!");
        }
        return mapper.insert(mTheartbeat);
    }
    @Override
    public List<MTheartbeat> query() {
        return mapper.fetch(" ORDER BY HEARTBEAT_ID DESC ");
    }
}
